//
//  LoginRegisterAreaView.swift
//  GLUZSwift
//
//  Created by xyanl on 2025/3/7.
//  Copyright © 2025 考拉🐨. All rights reserved.
//

import UIKit
import Reusable
import Localize_Swift

extension LoginRegisterAreaView: NibLoadable {}

class LoginRegisterAreaView: UIView {

    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var chineseRequiredLabel: UILabel!
    @IBOutlet weak var ruRequiredLabel: UILabel!
    
    @IBOutlet weak var infoView: UIView!
    @IBOutlet weak var contentTextField: UITextField!
    
    var didClickSelecteAreaListBlock: (() -> Void)?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        infoView.addRoundedCorners(radius: 10)
        infoView.sg.addTapGesture(self, #selector(didClickSelecteAreaList))
        chineseRequiredLabel.addRoundedCorners(radius: 8)
        
        /// 监听语言的变化
        NotificationCenter.default.addObserver(self, selector: #selector(updateLanguageAction), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil)
        updateLanguageAction()
    }
    
    @objc func didClickSelecteAreaList() {
        didClickSelecteAreaListBlock?()
    }
    
    // 更新语言
    @objc private func updateLanguageAction() {
        
        titleLabel.text = "所在地区".localized(.login)
        contentTextField.placeholder = "请选择所在地区".localized(.login)
       
        if LanguageManager.isLanguageZH {
            chineseRequiredLabel.isHidden = false
            ruRequiredLabel.isHidden = true

        } else {            
            chineseRequiredLabel.isHidden = true
            ruRequiredLabel.isHidden = false
        }
        
    }
}
